{% extends 'myadmin/base.html' %}
{%block body%}
<div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
                Amaze UI 文字列表
            </div>
            <ol class="am-breadcrumb">
                <li><a href="#" class="am-icon-home">首页</a></li>
                <li><a href="#">Amaze UI CSS</a></li>
                <li class="am-active">文字列表</li>
            </ol>
            <div class="tpl-portlet-components">
                <div class="portlet-title">
                    <div class="caption font-green bold">
                        <span class="am-icon-code"></span> 用户列表
                    </div>
                    <div class="tpl-portlet-input tpl-fz-ml">
                        <div class="portlet-input input-small input-inline">
                            
                        </div>
                    </div>


                </div>
                <div class="tpl-block">

                    <form action="">
                    <div class="am-g">
                        <div class="am-u-sm-12 am-u-md-6">
                            <div class="am-btn-toolbar">
                                
                            </div>
                        </div>
                        <div class="am-u-sm-12 am-u-md-3">
                            <div class="am-form-group">
                                <select name="type" data-am-selected="{btnSize: 'sm'}" style="display: none;">
                                    <option {% if request.GET.type == 'all' %}selected {% endif %} value="all">所有类别</option>
                                    <option {% if request.GET.type == 'uname' %}selected {% endif %} value="name">用户名</option>
                                    <option {% if request.GET.type == 'uphone' %}selected {% endif %} value="phone">手机号</option>
                                    <option {% if request.GET.type == 'uQQ' %}selected {% endif %} value="QQ">QQ</option>
                                </select>
                            </div>
                        </div>
                        <div class="am-u-sm-12 am-u-md-3">
                            <div class="am-input-group am-input-group-sm">
                                <input type="text" name="search" class="am-form-field" value="{{request.GET.search}}">
                                <span class="am-input-group-btn">
            <button class="am-btn  am-btn-default am-btn-success tpl-am-btn-success am-icon-search"></button>
          </span>
                            </div>
                        </div>
                    </div>
                    </form>

                    <div class="am-g">
                        <div class="am-u-sm-12">
                            <form class="am-form">
                                <table class="am-table am-table-striped am-table-hover table-main">
                                    <thead>
                                        <tr>
                                            <th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>
                                            <th class="table-id">ID</th>
                                            <th class="table-title">用户名</th>
                                            <th class="table-author am-hide-sm-only">电子邮箱</th>
                                            
                                            <th class="table-type">手机号</th>
                                            <th class="table-author am-hide-sm-only">QQ</th>
                                            <th class="table-date am-hide-sm-only">状态</th>
                                            <th class="table-date am-hide-sm-only">添加时间</th>
                                            <th class="table-set">操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        {% for i in userinfo %}
                                        <tr>
                                            <td><input type="checkbox"></td>
                                            <td>{{i.id}}</td>
                                            <td>{{i.uname}}</td>
                                            <td>{{i.uemail}}</td>
                                            <td>{{i.uphone}}</td>
                                            <td>{{i.uQQ}}</td>
                                            <td>
                                                <select style="background:blue" class="changes" uid="{{i.id}}">
                                                    <option {% if i.ustatus == 0 %}selected {% endif %} value="0">正常</option>
                                                    <option {% if i.ustatus == 1 %}selected {% endif %} value="1">禁用</option>
                                                </select>
                                            </td>
                                            <td>{{i.uaddtime}}</td>
                                            <td>
                                                <div class="am-btn-toolbar">
                                                    <div class="am-btn-group am-btn-group-xs">
                                                        <button class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 
                                                            <a href="{% url 'myadmin_edituser' %}?uid={{i.id}}">
                                                                编辑
                                                            </a>
                                                        </button>
                                                        <button class="am-btn am-btn-default am-btn-xs am-hide-sm-only">
                                                            <a href="javaScript:void(0)" uid={{i.id}} class="changepwd tpl-table-black-operation-del">
                                                                <i class="am-icon-trash"></i> 重置密码
                                                            </a>
                                                        </button>
                                                        <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only"><span class="am-icon-trash-o"></span>
                                                            <a href="{% url 'myadmin_deluser' %}?uid={{i.id}}" class="tpl-table-black-operation-del">
                                                                删除
                                                            </a>
                                                        </button>
                                                    </div>
                                                </div>
                                            </td>
                                        </tr>
                                        {% endfor %}
                                    </tbody>
                                    
                                </table>


                                <div class="am-cf">
                                    <div class="am-fr">
                                        <ul class="am-pagination tpl-pagination">
                                            <li ><a href="{% url 'myadmin_userlist' %}?p=1&type={{request.GET.type}}&search={{request.GET.search}}">首页</a></li>

                                            <li {% if page == 1 %}class="am-disabled"{% endif %}><a href="{% url 'myadmin_userlist' %}?p={{page|add:-1}}&type={{request.GET.type}}&search={{request.GET.search}}">«</a></li>
                                            {% for i in prange %}
                                            <li {% if page == i %} class="am-active" {% endif %}><a href="{% url 'myadmin_userlist' %}?p={{i}}&type={{request.GET.type}}&search={{request.GET.search}}">{{i}}</a></li>
                                            {% endfor %}
                                            <li {% if page == sumpage %}class="am-disabled"{% endif %}><a href="{% url 'myadmin_userlist' %}?p={{page|add:1}}&type={{request.GET.type}}&search={{request.GET.search}}">»</a></li>

                                            <li ><a href="{% url 'myadmin_userlist' %}?p={{sumpage}}&type={{request.GET.type}}&search={{request.GET.search}}">尾页</a></li>
                                        </ul>

                                    </div>
                                </div>
                                <hr>

                            </form>
                        </div>

                    </div>
                </div>
                <div class="tpl-alert"></div>
            </div>
        </div>
{%endblock%}

{% block script %}
<script type="text/javascript">
// 重置密码
$('.changepwd').click(function(){
    // 获uid
    var uid=$(this).attr('uid')
    console.log(uid)
    // 放ajax请求 重置密码
    $.get('{% url "myadmin_respwd" %}',
            {id:uid},
            function(data){
                alert(data.msg)
            },'json')
})
// 修改状态
$('.changes').change(function(){
    // 获取用户id
    var uid = $(this).attr('uid')
    // 获取value值
    var val = $(this).val()
    // 发送ajax
    $.get('{% url "myadmin_changes" %}',{id:uid,ustatus:val},function(data){
        alert(data.msg)
    },'json')
})
</script>
{% endblock %}